<template>

  <div>
    <div id="icon">
      <i class="el-icon-s-data"></i>
      学生课程
    </div>
    <div id="formView">
      <el-row>
        <el-col :span="24">
          <el-table
            :data="tableData"
            stripe
            style="width: 100%">
            <el-table-column
              prop="scId"
              label="选课id"
              width="180">
            </el-table-column>
            <el-table-column
              prop="courseName"
              label="课程名"
              width="180">
            </el-table-column>
            <el-table-column
              prop="teacherName"
              label="教师">
            </el-table-column>
            <el-table-column
              prop="courseCredit"
              label="学分">
            </el-table-column>
            <el-table-column
              prop="scDailyScore"
              label="日常成绩">
            </el-table-column>
            <el-table-column
              prop="scExamScore"
              label="考试成绩">
            </el-table-column>
            <el-table-column
              prop="scScore"
              label="总成绩">
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="danger"
                  @click="handleEdit(scope.$index, scope.row)">退选
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>

    </div>
  </div>
</template>

<script>
  import {get, post} from "../../../common/request";

  export default {
    name: "StudentCourse",
    data() {
      return {
        tableData:[]
      }
    },
    methods: {
      handleEdit(index, row) {
        post("/rc-student-course/changeCourse/"+row.scId).then(x=>{
          if (x.code==1){
            this.$message({
              message: x.msg,
              type: 'success'
            });
            this.getData();
          }else{
            this.$message({
              message: x.msg,
              type: 'error'
            });
          }
        })
      },
      getData(){
        get("/rc-student-course/showStudentCourse").then(x=>{
          this.tableData = x.data;
        });
      }
    },
    mounted(){
      this.getData();
    }
  }
</script>

<style scoped>
  #icon{
    text-align: left;
    color: gray;
    line-height: 20px;
  }
  #formView{
    background-color: white;
    border-radius: 5px;
    border: 1px solid lightgrey;
    margin-top: 10px;
    padding: 10px 30px 10px 30px;
  }





</style>
